package com.yunji.base.consumer;

import com.yunji.base.bo.ChangeBindBO;
import com.yunji.cabinet.bo.CabinetBO;
import com.yunji.cabinet.bo.CabinetListQueryBO;
import com.yunji.cabinet.domain.CabinetSiteDO;
import com.yunji.cabinet.provide.CabinetProvide;
import com.yunji.cabinet.provide.CabinetSiteProvide;
import com.yunji.cabinet.provide.CabinetTemplateProvide;
import com.yunji.order.bo.ExistsOrderBO;
import com.yunji.order.provide.OrderProvide;
import com.yunji.product.bo.ProductAgentListQueryBO;
import com.yunji.common.model.cache.ProductBelongCacheDTO;
import com.yunji.product.bo.ProductSelectQueryBO;
import com.yunji.product.domain.ProductAgentDO;
import com.yunji.product.provide.ProductAgentProvide;
import com.yunji.product.provide.ProductProvide;
import com.yunji.system.provide.SystemProvide;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : peter-zhu
 * @date : 2024/12/12 15:21
 * @description : TODO
 **/
@Component
public class BaseDataConsumer {
    @Resource
    CabinetProvide cabinetProvide;

    @Resource
    CabinetSiteProvide cabinetSiteProvide;

    @Resource
    CabinetTemplateProvide cabinetTemplateProvide;

    @Resource
    SystemProvide systemProvide;

    @Resource
    ProductAgentProvide productAgentProvide;

    @Resource
    ProductProvide productProvide;

    @Resource
    OrderProvide orderProvide;


    public boolean existsOrder(ExistsOrderBO build) {
        return orderProvide.existsOrder(build);
    }

    public boolean existsOrderBySiteIds(List<Long> siteIds) {
        return orderProvide.existsOrderBySiteIds(siteIds);
    }

    public String selectConfigByKey(String configKey) {
        return systemProvide.selectConfigByKey(configKey);
    }

    public boolean createProductAgent(ProductAgentDO pa) {
        return productAgentProvide.create(pa);
    }

    public List<ProductAgentDO> searchProductAgent(ProductAgentListQueryBO bo) {
        return productAgentProvide.search(bo);
    }

    public void deletePAByManagerIds(Long... ids) {
        productAgentProvide.deleteByManagerIds(ids);
    }

    public void updateProductAgent(ProductAgentDO productManager) {
        productAgentProvide.update(productManager);
    }

    public  List<CabinetSiteDO> searchCSBySiteIds(Long... ids) {
        return cabinetSiteProvide.searchBySiteIds(ids);
    }

    public void changeTemplateAgent(ChangeBindBO bo) {
        cabinetTemplateProvide.changeAgent(bo);
    }

    public void changeCabinetAgent(ChangeBindBO bo) {
        cabinetProvide.changeCabinetAgent(bo);
    }

    public List<CabinetBO> searchCabinetList(CabinetListQueryBO bo) {
        return cabinetProvide.searchList(bo);
    }

    public CabinetBO selectCabinet(Long cabinetId) {
        return cabinetProvide.selectCabinet(cabinetId);
    }

    public ProductBelongCacheDTO selectProduct(Long belongId, Long productId) {
        return productProvide.selectProduct(ProductSelectQueryBO.builder().belongId(belongId).productId(productId).build());
    }

    public boolean containerExistsSiteLocation(List<Long> locationIds) {
        return cabinetProvide.containerExistsSiteLocation(locationIds);
    }
}
